package com.ktjiaoyu.crm.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktjiaoyu.crm.pojo.Role;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoleMapper extends BaseMapper<Role> {

    /**
     * 分页查询角色信息
     * @param page
     * @param queryWrapper
     * @return
     */
    List<Role> selectRolePages(Page page, @Param(Constants.WRAPPER) Wrapper<Role> queryWrapper);


    /**
     * 根据用户ID查询用户所拥有角色
     * @param usrId
     * @return
     */
    @Select("select r.* from sys_role r left join sys_user u on r.role_id=u.usr_role_id where u.usr_id=#{usrId}")
    Role findRoleByUserId(@Param("usrId") Long usrId);
}
